package com.ForeHome.app.Controller;

import com.ForeHome.app.Service.CategoryService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tamll.Type.DataType;
import com.tamll.bean.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CategoryController {


    @Autowired
    private CategoryService categoryService;

    /**
     * 查询所有分类信息
     * @return 返回查询数据
     */
    @GetMapping("sortAll")
    public DataType sortAll(){
        Page<Category> page = categoryService.listAll();
        DataType dataType=new DataType();
        dataType.setData(page.getRecords());
        return dataType;
    }


    @GetMapping("sortName")
    public DataType sortName(){
        DataType dataType=new DataType();
        List<Category> categories = categoryService.listCategoryName();
        dataType.setData(categories);
        return dataType;
    }


    @GetMapping("selectCategoryName")
    public Category selectCategoryName(Integer productId){
        return categoryService.selectCategoryName(productId);
    }



}
